//Author: Jair Cazarin <slipvayne@gmail.com>

#include<iostream>
#include<stdio.h>
#include<math.h>
#define MAX 1000

using namespace std;

int n; 
double money[MAX+1];
double average = 0.0;
double lessThanAverage = 0.0;
double moreThanAverage = 0.0;
double result;
bool debug = false;

void print() {	
	printf("$%.2f\n", result);
}

double getAverage(double average)
{
	return ((int)((average * 100) / n)) / 100.0;
}

void solve()
{
	for(int i=0; i<n; i++)
		average += money[i];
	
	if(debug)
		printf("%f\n", average);  
	average = getAverage(average);
	if(debug)
		printf("%f\n", average);
	for(int i=0; i<n; i++)
	{
		//Key
		if(average >= money[i])
			lessThanAverage += average - money[i];
		else
			moreThanAverage += money[i] - (average + 0.01);
	}
	
	if(debug)
		printf("%f %f", moreThanAverage, lessThanAverage);
	if(moreThanAverage > lessThanAverage)
		result = moreThanAverage;
	else
		result = lessThanAverage;
}

void read() {
	
	scanf("%d", &n);
	
	while(true) {
		for(int i=0; i<n; i++) {
			cin >> money[i];
			if(debug)
				printf("%f ", money[i]);
		}
		if(debug)
			printf("\n");

		solve();
		print();
		average = 0;
		lessThanAverage = 0;
		moreThanAverage = 0;
		scanf("%d", &n);
		if(n == 0)
			break;
	}
}

int main()
{
	read();
	return 0;
}
